home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / winvn060.arc / WVGLOB.H < prev    next >
C/C++ Source or Header  |  1991-07-01  |  15KB  |  406 lines

  1. /*---  This is WVGLOB.H  ------------------------------------------- */
  2. /* WVGLOB.H contains all the global types and variables for WinVN.   */
  3. /* Stylistically, this should probably be separated into several     */
  4. /* header files, but this is what you've got for now.                */
  5. /* cf WVDOC.C -- it describes some of these structures.              */
  6.  
  7. #define BUFSIZE   1024
  8. #define MAXFINDSTRING  80
  9.  
  10. typedef long TypLineID;
  11.  
  12. typedef struct structdoc {
  13.    HANDLE hFirstBlock;        /* handle to first textblock in doc.        */
  14.    HANDLE hLastBlock;         /* unused.                                  */
  15.    unsigned int TotalLines;   /* total # of lines in doc.                 */
  16.    unsigned int ActiveLines;  /* # of selected or otherwise active lines  */
  17.    unsigned int BlockSize;    /* # of bytes in a textblock                */
  18.    unsigned int SplitSize;    /* textblock split point in bytes           */
  19.    HANDLE hCurAddBlock;       /* hBlock to point at which to add lines.   */
  20.    unsigned int AddOffset;    /* offset in bytes for point to add lines   */
  21.    TypLineID  AddLineID;      /* LineID of point to add lines.            */
  22.    HANDLE hCurTopScBlock;     /* hBlock of current top line of window     */
  23.    unsigned int TopScOffset;
  24.    TypLineID  TopScLineID;
  25.    unsigned int TopLineOrd;   /* ordinal in doc of line line in window    */
  26.    HANDLE hLastSeenBlock;
  27.    unsigned int LastSeenOffset;
  28.    TypLineID    LastSeenLineID;
  29.    HANDLE hFindBlock;         /* location of place to start next search   */
  30.    unsigned int FindOffset;   /* for "SearchStr"                          */
  31.    TypLineID    FindLineID;
  32.    unsigned int FindTextOffset;
  33.    char SearchStr[MAXFINDSTRING];  /* Search string for current search    */
  34.    unsigned int ScXChars;     /* # of chars/line for current window size  */
  35.    unsigned int ScYLines;     /* # of lines that fit in current window    */
  36.    unsigned int ScXWidth;     /* current size of client area of window    */
  37.    unsigned int ScYHeight;
  38.    HWND hDocWnd;
  39.    struct structdoc *ParentDoc;  /* pointer to parent document            */
  40.    HANDLE hParentBlock;          /* points to line in parent doc          */
  41.    unsigned int ParentOffset;    /* that corresponds to/describes this    */
  42.    TypLineID    ParentLineID;    /* document                              */
  43.    unsigned int OffsetToText;
  44.    BOOL          InUse;          /* TRUE if this TypDoc in use.           */
  45.    int          DocType;         /* DOCTYPE_xxx                           */
  46. #ifdef MAC
  47.    RECT  DocClipRect;      /* Current window clip rectangle          */
  48. #endif
  49. } TypDoc;
  50.  
  51. typedef struct structblock {
  52.    HANDLE hPrevBlock;     /* handle of previous block, or 0               */
  53.    HANDLE hNextBlock;     /* handle of next block in document, or 0       */
  54.    HANDLE hCurBlock;      /* handle of this block                         */
  55.    int    LWAp1;          /* # of used data bytes in block, inc header    */
  56.    int    NumLines;       /* # of lines in this block                     */
  57.    TypDoc *OwnerDoc;      /* pointer to document this block is in.        */
  58.    int    eob;            /* end-of-block; must be just before 1st line.  */
  59.    /* Text lines */
  60.    /* Another EOB marker */
  61. } TypBlock;
  62.  
  63. typedef struct structline {
  64.    int length;              /* Total # of bytes in line, all-inclusive    */
  65.    TypLineID LineID;        /* Unique identifier for this line.           */
  66.    /* Bytes of text */
  67.    /* Another copy of length */
  68. } TypLine;
  69.  
  70. typedef struct structtext {
  71.    int NameLen;            /* # of bytes of text                          */
  72. } TypText;
  73.  
  74. typedef struct structgroup {
  75.    char          Subscribed;      /* =TRUE if subscribed to this group.   */
  76.    char          Selected;        /* =TRUE if selected                    */
  77.    int           NameLen;         /* # of bytes in group name             */
  78.    TypDoc        *SubjDoc;        /* points to doc containing subjs       */
  79.    unsigned int  ServerEstNum;    /* est # of arts in server              */
  80.    long int  ServerFirst;     /* # of first art that server has.      */
  81.    long int  ServerLast;      /* # of last art that server has.       */
  82.    long int  HighestPrevSeen;     /* # of highest art server had in last  */
  83.                                   /* session, from "s<num>" newsrc field  */
  84.    int  nRanges;                  /* # of TypRanges describing seen arts  */
  85.    /* Name of group */            /* name of group, zero-terminated       */
  86.    /* Ranges of articles seen */  /* array of TypRanges, of seen articles */
  87. } TypGroup;
  88.  
  89. typedef struct structarticle {
  90.    long int Number;            /* Server's number for this article    */
  91.    char         Seen;              /* =TRUE if article seen               */
  92.    char         Selected;          /* =TRUE if article selected           */
  93.    TypDoc      *ArtDoc;            /* points to doc with actual article   */
  94.    int         NameLen;       /* # of bytes in subject line */
  95.    /* Subject line of article */
  96. } TypArticle;
  97.  
  98. typedef struct structrange {
  99.    long int   First;
  100.    long int   Last;
  101. } TypRange;
  102.  
  103. /* TypMRRFile is used to describe a file; I use it because Windows  */
  104. /* doesn't provide much in the way of disk I/O support.                   */
  105.  
  106. typedef struct structMRRfile {
  107.    HANDLE   hFile;           /* handle to file                            */
  108. #ifdef MAC
  109.    int      vRef;
  110. #else
  111.    OFSTRUCT of;
  112. #endif
  113.    char     buf[BUFSIZE];    /* my I/O buffer.                            */
  114.    HANDLE   hthis;           /* handle to this structure                  */
  115.    int      bufidx;          /* Index to next place in buf                */
  116.    int      bytesread;       /* for reads, # of bytes read in last read   */
  117.    int      mode;            /* mode in which to open file.               */
  118.    int      eofflag;         /* whether we have reached EOF (read)        */
  119. } TypMRRFile;
  120.  
  121. #define MAXCHARS 80
  122. #define MAXLINES 24
  123. #define MAXCOMMLINE      140
  124. #define MAXINTERNALLINE   180
  125. #define MAXOUTLINE    255
  126. #define CtoX(c) (c*CharWidth + SideSpace)
  127. #define LtoY(l) (l*LineHeight + TopSpace)
  128.  
  129. #define EDITID   1      /* ID of edit box, to identify for return values */
  130. #define MAXMEMONAME 15  /* Number of chars in memo name */
  131. #define MEMONAMECHARS (MAXMEMONAME+2)
  132. #define MAXVIEWS 10
  133. #define END_OF_BLOCK (-1)
  134. #define BLOCK_SIZE  1024
  135. /*  RangeOffset gives the number of bytes from the beginning of
  136.  *  a Group structure to the first Range field, given the length
  137.  *  of the name entry.
  138.  */
  139. #define RangeOffset(nlen) (((nlen+2)/2)*2 + sizeof(TypGroup))
  140.  
  141. #ifdef WINMAIN
  142. #define DEF
  143. #else
  144. #define DEF extern
  145. #endif
  146.  
  147. DEF TypDoc NetDoc;
  148.  
  149. #define MRR_SCROLL_LINEUP    0
  150. #define MRR_SCROLL_LINEDOWN  1
  151. #define MRR_SCROLL_PAGEUP    2
  152. #define MRR_SCROLL_PAGEDOWN  3
  153.  
  154.  
  155. /* This structure maps between keystrokes and mouse events.
  156.  * From an idea on p. 137 of Charles Petzold's book.
  157.  * If you change the definition, be sure to update NUMKEYS.
  158.  */
  159. #define NUMKEYS 4
  160. #ifndef MAC
  161. struct {
  162.    WORD wVirtKey;
  163.    int CtlState;
  164.    int iMessage;
  165.    WORD wRequest;
  166. } key2scroll[NUMKEYS]
  167. #ifdef WINMAIN
  168. =
  169. {VK_PRIOR, 0, WM_VSCROLL,SB_PAGEUP,
  170.  VK_NEXT,  0, WM_VSCROLL,SB_PAGEDOWN,
  171.  VK_UP,    1, WM_VSCROLL,SB_LINEUP,
  172.  VK_DOWN,  1, WM_VSCROLL,SB_LINEDOWN
  173. }
  174. #endif
  175. ;
  176. #endif
  177.  
  178. DEF BOOL Initializing;
  179. #define INIT_DONE                0
  180. #define INIT_READING_NEWSRC      1
  181. #define INIT_ESTAB_CONN          2
  182. #define INIT_SCANNING_NETDOC     3
  183. #define INIT_GETTING_LIST        4
  184.  
  185. #define MAXGROUPWNDS   4
  186. #define MAXARTICLEWNDS 4
  187. #define MAXPOSTWNDS    4
  188. #define MAXMAILWNDS    4
  189.  
  190. DEF TypDoc GroupDocs[MAXGROUPWNDS];
  191. DEF TypDoc ArticleDocs[MAXARTICLEWNDS];
  192. DEF TypDoc PostingDocs[MAXPOSTWNDS];
  193. DEF TypDoc MailDocs[MAXMAILWNDS];
  194. DEF HWND  hWndPosts[MAXPOSTWNDS];
  195. DEF HWND  hWndMails[MAXMAILWNDS];
  196. #ifndef MAC
  197. DEF HWND  hWndPostEdits[MAXPOSTWNDS];
  198. DEF HWND  hWndMailEdits[MAXMAILWNDS];
  199. #else
  200. DEF TEHandle TEHPosts[MAXPOSTWNDS];
  201. DEF TEHandle TEHCurrent;
  202. DEF ControlHandle    vScroll;
  203. DEF int           linesInFolder;
  204. #endif
  205.  
  206. #define DOCTYPE_UNKNOWN  0
  207. #define DOCTYPE_NET      1
  208. #define DOCTYPE_GROUP    2
  209. #define DOCTYPE_ARTICLE  4
  210. #define DOCTYPE_POSTING  8
  211. #define DOCTYPE_MAIL     16
  212.  
  213. /* Variables and constants for handling the FSA used to deal with    */
  214. /* talking to the NNTP server.                                       */
  215.  
  216. DEF int CommState;        /* current state in comm FSA                        */
  217. DEF BOOL CommBusy;        /* =TRUE if comm line busy interacting w/ server    */
  218. DEF TypDoc *CommDoc;      /* Document currently receiving lines from server   */
  219. DEF char CommLineIn[MAXCOMMLINE];  /* current input line being built by FSA   */
  220. DEF char *CommLinePtr;    /* pointer to next place to put char in CommLineIn  */
  221. DEF char *CommLineLWAp1;  /* if we get this far, we're at end of buffer       */
  222. DEF char IgnoreCommCh;    /* char to ignore when reading from server          */
  223. DEF char EOLCommCh;       /* char that indicates end of line upon input       */
  224. DEF TypDoc *ActiveGroupDoc;
  225. DEF TypDoc *ActiveArticleDoc;
  226. DEF BOOL SaveNewsrc;      /* =TRUE iff we write NEWSRC upon exit */
  227.  
  228. #define MAXGROUPNAME 80
  229. DEF char CurrentGroup[MAXGROUPNAME]; /* name of group currently selected on server */
  230.  
  231. DEF BOOL UsingSocket;     /* =TRUE if using PC/TCP rather than serial I/O     */
  232. #define MAXNNTPSIZE 40
  233. DEF char NNTPIPAddr[MAXNNTPSIZE];
  234. DEF int NNTPPort;
  235.  
  236. #define MAILLEN 48
  237. DEF char MailAddress[MAILLEN];
  238. DEF char UserName[MAILLEN];
  239. DEF char Organization[MAILLEN];
  240.  
  241.  
  242. /* States in the FSA that cracks input lines from the server.             */
  243.  
  244. #define ST_NONE                    0
  245. #define ST_ESTABLISH_COMM          1
  246. #define ST_GROUP_RESP              2
  247. #define ST_XHDR_RESP               3
  248. #define ST_XHDR_SUBJ               4
  249. #define ST_IN_GROUP                5
  250. #define ST_ARTICLE_RESP            6
  251. #define ST_REC_ARTICLE             7
  252. #define ST_POST_WAIT_PERMISSION    8
  253. #define ST_POST_WAIT_END           9
  254. #define ST_GROUP_REJOIN           10
  255. #define ST_LIST_RESP              11
  256. #define ST_LIST_GROUPLINE         12
  257. #define ST_MAIL_WAIT_PERMISSION   13
  258. #define ST_MAIL_WAIT_END          14
  259.  
  260. #define LFN_HELP "WINVN.HLP"
  261.  
  262. /* variables used in an ad hoc attempt to optimize updating of windows by
  263.  * the input cracking FSA.
  264.  */
  265.  
  266. #define UPDATE_TITLE_FREQ    10
  267. #define UPDATE_ART_FREQ    12
  268. #define MAX_IMMEDIATE_UPDATE  2
  269. DEF unsigned int RcvLineCount;
  270. DEF unsigned int TimesWndUpdated;
  271.  
  272. DEF TypLineID NextLineID  /* LineID to assign to next created line            */
  273. #ifdef WINMAIN
  274. = 10664L
  275. #endif
  276. ;
  277.  
  278. DEF HANDLE hInst;
  279. DEF HWND   hWndConf;   /* handle to NetDoc window                             */
  280. DEF HWND   hWndSk;
  281. DEF HWND   hDosWnd;
  282.  
  283. #ifndef MAC
  284. HANDLE hAccel;     /* handle to main accelerator table */
  285. MSG MainMsg;       /* message returned from GetMessage */
  286.  
  287. int CommDevice;    /* comm device ID, if using serial I/O                 */
  288. #endif
  289.  
  290.  
  291. DEF char str[255];                              /* general-purpose string buffer */
  292.  
  293. #ifndef MAC
  294. HCURSOR hSaveCursor;                        /* handle to current cursor      */
  295. HCURSOR hHourGlass;                         /* handle to hourglass cursor    */
  296. #endif
  297.  
  298. DEF int X, Y;                                   /* last cursor position          */
  299.  
  300. #ifndef MAC
  301. POINT ptCursor;                             /* x and y coordinates of cursor */
  302.  
  303. DCB DCBComm;
  304. #define MAXCOMMCHARS 40
  305. char szCommString[MAXCOMMCHARS];    /* string describing serial comm port */
  306. #endif
  307.  
  308. DEF int xPos, yPos;
  309.  
  310. DEF int ViewNew;
  311. DEF int NewArticleWindow;
  312. DEF int SelectAll;
  313. DEF int NViews;
  314. DEF int DoList;
  315.  
  316. DEF unsigned int xScreen, yScreen;
  317. DEF HANDLE hFont;   /* handle to font used in all windows                     */
  318. DEF int FontSize;
  319. DEF int FontBold;
  320. DEF char FontFace[32];
  321. DEF int LineHeight,CharWidth;  /* # of window units for current font          */
  322. DEF int TopSpace, SideSpace;   /* # of window units to leave at top and side  */
  323.                            /* of window (for aesthetic purposes)          */
  324. DEF int StartPen;      /* Similar to TopSpace; where to start pen 1st row */
  325.  
  326. DEF DWORD OldTextColor, OldBkColor;
  327. DEF DWORD NetUnSubscribedColor;  /* color to use for unsubscribed groups  */
  328. DEF DWORD GroupSeenColor;        /* color to use for articles that have been seen */
  329. DEF int ReverseVideo;
  330. DEF BOOL ThumbTrack;
  331. #ifdef MAC
  332. DEF RgnHandle BigClipRgn;
  333. DEF   Rect  myClipRect;
  334.  
  335. DEF Handle netMenuBar,groupMenuBar,articleMenuBar,postMenuBar;
  336. DEF MenuHandle gAppleMenu;
  337. DEF MenuHandle gOptionsMenu;
  338. #endif
  339.  
  340. #ifndef MAC
  341. FARPROC lpfnWinVnSaveArtDlg;
  342. FARPROC lpfnWinVnFindDlg;
  343. FARPROC lpfnWinVnCommDlg;
  344. FARPROC lpfnWinVnAuthDlg;
  345. FARPROC lpfnWinVnDoListDlg;
  346. FARPROC lpfnWinVnPersonalInfoDlg;
  347. FARPROC lpfnWinVnMiscDlg;
  348. FARPROC lpfnWinVnAppearanceDlg;
  349. char *szAppName;
  350. #endif
  351.  
  352. DEF BOOL Authorized;
  353.  
  354. #define MAXFILENAME 60
  355. DEF char SaveArtFileName[MAXFILENAME];
  356. DEF int  SaveArtvRef;   /* volume ref num used only by Mac */
  357. DEF int  SaveArtAppend;
  358.  
  359. DEF TypDoc *PostDoc;   /* Used to pass pointer to article being replied to. */
  360. DEF TypDoc *MailDoc;
  361. DEF TypDoc *FindDoc;
  362. DEF char *NewsgroupsPtr;  /* Used to pass pointer to newsgroup of new posting. */
  363.  
  364. /* For each new group detected, we create an entry in the following
  365.  * array, NewGroupTable.  Each entry contains a far pointer to a
  366.  * dynamically-allocated global data structure containing:
  367.  *  -- Handle to this structure (so we can deallocate later).
  368.  *  -- A line containing information on this group, in the exact
  369.  *     same format as used in the NetDoc.
  370.  */
  371. DEF void far * far * NewGroupTable;  /* array of pointers to new group lines */
  372. DEF HANDLE hNewGroupTable;     /* Handle to the above array */
  373. DEF int nNewGroups;
  374.  
  375. #define ADD_SUBSCRIBED_END_OF_SUB 0
  376. #define ADD_SUBSCRIBED_TOP_OF_DOC        1
  377.  
  378. #define LINE_FLAG_SET        0
  379.  
  380. #define GROUP_ACTION_SUBSCRIBE    0
  381. #define GROUP_ACTION_UNSUBSCRIBE  1
  382.  
  383. DEF int il,ic;
  384. DEF int irow;
  385. DEF int imemo;
  386. DEF int ih;
  387.  
  388. #define MAXCOMMSPEEDCHARS 7
  389.  
  390. DEF int CommPortID;     /* IDD_COM1 or IDD_COM2 */
  391. DEF int CommParityID;   /* IDD_7EVEN or IDD_8NONE  */
  392. DEF char pszCommSpeed[MAXCOMMSPEEDCHARS];  /* character version of comm speed */
  393.  
  394. DEF int idTimer;                                          /* timer ID            */
  395.  
  396. #ifndef MAC
  397. #define IncPtr(ptr,byint) (char far *)ptr += byint
  398. #endif
  399.  
  400. #include <string.h>
  401. #ifndef MAC
  402. int _FAR_ _cdecl sprintf(char _FAR_ *, const char _FAR_ *, ...);
  403. int _FAR_ _cdecl sscanf(const char _FAR_ *, const char _FAR_ *, ...);
  404. #endif
  405. /*--- Last line of WVGLOB.H -------------------------------------------- */
  406.